<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function f() {
            var zfc1 = document.getElementById("zfc1");
            var zfc2 = document.getElementById("zfc2");
            var result = document.getElementById("result");
            var num =0;
            var start=0;
            while (true){
                var index = zfc2.value.indexOf(zfc1.value,start);
                if (index!=-1){
                    num++;
                    start=index+1;
                }else {
                    break;
                }
            }
            result.innerHTML="["+zfc1.value+"]在["+zfc2.value+"]中一共出现:"+num+"次";
        }
    </script>
</head>
<body>
<input id="zfc1" type="text"/>
<input id="zfc2" type="text"/>
<input type="button" value="开始计算" onclick="f()"/>
<div id="result"></div>
</body>
</html>